// components/Location-Table/Location-Table.ts
interface locationInf {
    name: String
    location: String
    user: {
        name: String
        phone: String
    }
}

Component({
    /**
     * 组件的属性列表
     */
    properties: {
        locationList: {
            type: Array,
            value: []
        },
        isUpdate: {
            type: Boolean,
            value: false
        },
        type: {
            type: String,
            value: ''
        }
    },

    /**
     * 组件的初始数据
     */
    data: {},

    /**
     * 组件的方法列表
     */
    methods: {
        toLocationUpdate(e: any) {
            const info = encodeURIComponent(JSON.stringify(e.currentTarget.dataset.item))
            wx.navigateTo({
                url: `/pages/location/locationUpdate/locationUpdate?info=${info}`
            })
        },
        locationClick(e: any) {
            console.log(e.currentTarget.dataset.item)
            // @ts-ignore
            console.log(this.properties.type)
            let pages = getCurrentPages()
            let prevPage = pages[pages.length - 2] //上一个页面
            // @ts-ignore
            if (this.properties.type === 'start') {
                prevPage.setData({
                    startPoint: e.currentTarget.dataset.item
                })
            } else {
                prevPage.setData({
                    endPoint: e.currentTarget.dataset.item
                })
            }
            wx.navigateBack()
        },

        onShow() {}
    }
})
